package com.zqw.aop;

import com.zqw.util.DataUtil;
import com.zqw.util.StringUtil;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.util.ArrayList;

@Component
@Aspect
public class LoggerAop {


    @Pointcut("execution(* com.zqw.service.impl.*.*(..)) ")
    public void qrd1(){
    }
    @Pointcut("execution(* com.zqw.action.*.*(..)) ")
    public void qrd2(){
    }

    @Before("qrd1()")
    public void before(JoinPoint joinPoint){
        StringUtil.info("[zqw] "+ DataUtil.getData()+"开始执行:"+joinPoint.getTarget() +"  "+joinPoint.getSignature().getName()+"("+
              joinPoint.getArgs() + ")方法");
    }
    @Before("qrd2()")
    public void before2(JoinPoint joinPoint){
        StringUtil.info("[zqw] "+ DataUtil.getData()+"开始执行:"+joinPoint.getTarget() +"  "+joinPoint.getSignature().getName()+"("+
              joinPoint.getArgs() + ")方法");
    }

    @After("qrd1()")
    public void after(JoinPoint joinPoint) {
        StringUtil.info("[zqw] "+DataUtil.getData()+"执行完成:"+joinPoint.getTarget() +"  "+joinPoint.getSignature().getName()+"(" +
                joinPoint.getArgs() + ")方法");
    }
    @After("qrd2()")
    public void after2(JoinPoint joinPoint) {
        StringUtil.info("[zqw] "+DataUtil.getData()+"执行完成:"+joinPoint.getTarget() +"  "+joinPoint.getSignature().getName()+"(" +
                joinPoint.getArgs() + ")方法");
    }

}
